-
Notifications
You must be signed in to change notification settings - Fork 357
Add HTTP proxy configuration documentation for WordPress core and WP-CLI #623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds valuable documentation on configuring HTTP proxies for WP-CLI and WordPress core. The examples are clear and cover two important use cases. I've suggested a small improvement to the PHP examples to make them more robust by supporting HTTPS_PROXY and lowercase environment variables, which are common conventions.
| * uses for HTTP requests. | ||
| */ | ||
|
|
||
| $proxy_env = getenv( 'HTTP_PROXY' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current example only considers the HTTP_PROXY environment variable. It's a common practice to also support HTTPS_PROXY (for HTTPS requests) and lowercase variants (http_proxy, https_proxy).
Since WordPress Core doesn't differentiate between proxy settings for HTTP and HTTPS, it's best to prefer the HTTPS proxy variable if set, and fall back to the HTTP one. This makes the configuration more robust and aligns with user expectations.
| $proxy_env = getenv( 'HTTP_PROXY' ); | |
| $proxy_env = getenv( 'HTTPS_PROXY' ) ?: getenv( 'https_proxy' ) ?: getenv( 'HTTP_PROXY' ) ?: getenv( 'http_proxy' ); |
| * Configure HTTP proxy for both WordPress core and WP-CLI HTTP requests. | ||
| */ | ||
|
|
||
| $proxy_env = getenv( 'HTTP_PROXY' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current example only considers the HTTP_PROXY environment variable. It's a common practice to also support HTTPS_PROXY (for HTTPS requests) and lowercase variants (http_proxy, https_proxy).
Since WordPress Core doesn't differentiate between proxy settings for HTTP and HTTPS, it's best to prefer the HTTPS proxy variable if set, and fall back to the HTTP one. This makes the configuration more robust and aligns with user expectations.
| $proxy_env = getenv( 'HTTP_PROXY' ); | |
| $proxy_env = getenv( 'HTTPS_PROXY' ) ?: getenv( 'https_proxy' ) ?: getenv( 'HTTP_PROXY' ) ?: getenv( 'http_proxy' ); |
Documents manual proxy configuration for both WordPress core HTTP requests and WP-CLI's own HTTP requests. WP-CLI doesn't honor
HTTP_PROXYenvironment variable by default for security reasons.Changes
references/config.mdrequireconfig option to load proxy setup fileHTTP_PROXYenv var and sets WordPress proxy constants (WP_PROXY_HOST,WP_PROXY_PORT,WP_PROXY_USERNAME,WP_PROXY_PASSWORD)parse_url()http_request_argshook to configure the Requests libraryExamples
WordPress core HTTP requests only
wp-cli.yml:
proxy.php:
Both WordPress core and WP-CLI HTTP requests
proxy.php (extended):
Usage:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.